<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var number = 2;
        // var result = Math.floor(number); //向下取整
        // var result = Math.random(); //获取随机数
        // var result = Math.abs(number); //求绝对值
        // var result = Math.sqrt(number);  //开平方
        // var result = Math.pow(number,4); //计算乘方
        // 1 - 10的整数
        // var result = Math.floor(Math.random() * 10 + 1);
        // 1 - 7整数
        // var result = Math.floor(Math.random() * 7 + 1);
        // console.log(result);
        var list = ["钢铁侠","緑巨人","美国队长","蜘蛛侠","雷神"];
        var index = Math.floor(Math.random() * list.length);
        console.log(list[index]);
    </script>
</body>
</html>